// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init({
  env: "test4-ht5oe"
})

const db = cloud.database()
const _ = db.command
// 云函数入口函数
exports.main = async (event, context) => {

  try{
    const result =  db.collection('CommentsData').where({
      CommentID:event.id
    }).update({
      data: {
        Comments: _.push({
          each: [
            { Ccontent: event.content,
            CDate:event.date,
            Cimages:event.img,
            Coverall:event.rate
           }
          ],
        })
      }
    })

    return result
  } catch(e) {
    console.error(e)
  }
}